package com.tiancheng.trade.order.util;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @Author: likailun
 * @Description:
 * @Date: create in 2023/3/8 11:22
 */
@Slf4j
@Data
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "system.deduction")
public class DeductionCheckConfig {

    private List<DeductionCheckConfigItem> list;


    public String getUrl(String source, String system) {
        return list.stream().filter(item -> item.getSource().equals(source) && item.getSystem().equals(system)).findFirst().get().getUrl();
    }

    @Data
    public static class DeductionCheckConfigItem {
        /**
         * 场景
         */
        private String source;
        /**
         * 系统来源
         */
        private String system;
        /**
         * url
         */
        private String url;
    }

}
